﻿using UnityEditor;
using UnityEditor.AnimatedValues;

namespace EditorExtensions
{
    public class EditorGUILayoutAPI
    {
        private BuildTargetGroup m_BuildTargetGroup;
        private AnimBool mOpenFadeGroup = new AnimBool();
        private bool mFoldOutGroup = false;
        private bool mGroupValue;
        private bool mToggle1Value = false;
        private bool mToggle2Value = true;

        public void Draw()
        {
            mOpenFadeGroup.target = EditorGUILayout.ToggleLeft("Open Fade Group", mOpenFadeGroup.target);

            mFoldOutGroup = EditorGUILayout.BeginFoldoutHeaderGroup(mFoldOutGroup, "FoldOut");
            if(mFoldOutGroup)
            {
                EditorGUILayout.BeginFadeGroup(mOpenFadeGroup.faded);
                if(mOpenFadeGroup.target)
                {
                    m_BuildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();
                    EditorGUILayout.EndBuildTargetSelectionGrouping();
                }
                EditorGUILayout.EndFadeGroup();
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            
            mGroupValue = EditorGUILayout.BeginToggleGroup("全部设置", mGroupValue);
            mToggle1Value = EditorGUILayout.Toggle(mToggle1Value);
            mToggle2Value = EditorGUILayout.Toggle(mToggle2Value);
            EditorGUILayout.EndToggleGroup();
        }
    }
}